#include "str_utils.h"
#include <stdexcept>
uint64_t stringToUint64(const std::string& str) {
    std::string digits;
    digits.reserve(str.size());

    for (char c : str) {
        if (std::isdigit(static_cast<unsigned char>(c))) {
            digits += c;
        } else if (c == '.') {
            continue;  // 忽略小数点
        } else {
            throw std::invalid_argument("stringToUint64: 非数字字符: " + std::string(1, c));
        }
    }

    if (digits.empty()) {
        throw std::invalid_argument("stringToUint64: 输入字符串为空或无数字");
    }

    return std::stoull(digits);
}

void toUpper(std::string& s) {
    std::transform(s.begin(), s.end(), s.begin(),
                   [](unsigned char c){ return std::toupper(c); });
}

void toLower(std::string& s) {
    std::transform(s.begin(), s.end(), s.begin(),
                   [](unsigned char c){ return std::tolower(c); });
}